#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <stdlib.h>
void  swap(char* buff1, char* buff2, size_t width )
{
	char tmp = 0;
	int i = 0; 
	for (i = 0; i < width; i++)
	{
		tmp = *buff1;
		*buff1 = *buff2;
		*buff2 = tmp;
		buff1++;
		buff2++;

	}

 }
void bubble(void* base, size_t sz , size_t  width ,int ( *com )( const void *p1 ,const void * p2 ) )
{
	int i = 0;
	int j = 0;
	for (i = 0; i < sz-1; i++)

	{

		for (j = 0; j < sz - 1 - i; j++)
		{
			if (com((char*)base + j * width, (char*)base + (j + 1) * width )>0)
			{
				swap ((char*)base + j * width, (char*)base + (j + 1) * width,width );
			}


		}

	}

 }
void  print(int* arr, int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);

	}

 }
int  cmp_int(const void* p1, const void* p2)
{
	return (*(int*)p1) - (*(int*)p2);

 }
void test1()
{
	int  arr[] = { 1,4,2,3,5,6,7,9,8,10 };
	int sz = sizeof(arr)/sizeof(arr[0]);
	bubble(arr, sz, sizeof(arr[0]), cmp_int);
	print(arr, sz);
 }
int main()
{
	test1();
	


}